/*
 * string.c
 */

#include <string.h>

void itoa(int num, char *buffer)
{
	int n;
	int aux = num;
	for (n = 1; aux > 9; n++) aux /= 10;
	for (aux = 1; aux <= n; aux++) {
		buffer[n-aux] = '0' + num % 10;
		num /= 10;
	}
	buffer[n] = '\0';
}

int strlen(const char *string)
{
	int n;
	for (n = 0; string[n]; n++);
	return n;
}

int strcmp(const char *s1, const char *s2)
{
  int i = 0;
  while (s1[i] && s2[i] && s1[i] == s2[i]) {
    i++;
  }
  return s1[i] == s2[i];
}

void strcopy(char *s1, const char *s2)
{
  int i = 0;
  while (s2[i]) {
    s1[i] = s2[i];
    i++;
  }
  s1[i] = '\0';
}
